<script language="javascript">
/*验证表单*/
$(function(){
	$("#modishop").validate({
		event: "keyup",
		errorClass: "wrong",
		rules: {
			txtShopName: {required:true,minlength:3,maxlength:30},
			slcShopClass: {required:true},
			txtSaleRange: {required:true},
			area_id: {required:true}
		},
		messages: {
			txtShopName: {required: "<tpl> $langShopNameNotNull </tpl>",minlength:"<tpl> $errShopName3 </tpl>",maxlength:"<tpl> $errShopName3 </tpl>"},
			slcShopClass: {required: "<tpl> $langShopClassNotNull </tpl>"},
			txtSaleRange: {required: "<tpl> $errShopSaleRangeIsEmpty </tpl>"},
			area_id: {required:"<tpl> $langShopPleaseSelectLocus </tpl>"}
		}
	});
});

//地区选择
function tonext(whos) {
	$(whos).change(
		function(){
			var valarray=$(this).val().split('||');	
			$('#area_id').val(valarray[0]);
			if (valarray[1]=='1') {
				$(this).next().attr('disabled','true').html('<option value="" selected="selected"><tpl> $langCDataToLoading </tpl></option>');
				$.get(
					'../home/tohtml.php',
					{action:'get_area',id:valarray[0],random_number:Math.random()},
					function(data){
						DataArray = data.split("|||");
						var a='';
						for (var i = 0; i<DataArray.length-1; i++) {
							att=DataArray[i].split("||");
							id=att[0];
							cla=att[2];
							a+='<option value="'+id+'||'+cla+'">'+att[1]+((cla=='1')?' ->':'')+'</option>';
						}
						
					$(whos).next().removeAttr('disabled').html('<option value="" selected="selected"></option>'+a).nextAll().html('');
					tonext($(whos).next());
					}
				)
			} else {
				$(whos).nextAll().html('').attr('disabled','true');
			};
		}
	)
};
$().ready(function() {
	tonext('#c1');
});
</script>
